package ferp.android.views.table.element.text;

import android.content.Context;
import android.graphics.Rect;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.TextView;
import ferp.android.GUI;
import ferp.android.views.table.TableView;
import ferp.android.views.table.element.Element;

/**
 * User: olegs
 * Date: 04/01/2015 15:42
 */
public class FirstHand extends Element<TextView>
{
  public FirstHand(Context context, TableView parent) {super(context, parent);}

  public final void show(int resource, Rect area)
  {
    view.setBackgroundResource(resource);
    show(area);
  }

  @Override
  protected final TextView create(Context context, TableView parent)
  {
    TextView tv = new TextView(context);

    tv.setGravity(Gravity.CENTER);
    tv.setTypeface(GUI.Font.BOLD);
    tv.setTextColor(GUI.Color.NORMAL);
    tv.setText(FIRST);

    return tv;
  }

  @Override
  protected final void onBeforeLayout(Rect area) {view.setTextSize(TypedValue.COMPLEX_UNIT_PX, Math.round(area.height() / 2.5f));}

  private static final String FIRST = "1";
}
